import request from '../utils/request'

// 获取权限菜单列表
const getMenuList = (params = {}) => request.get(`/rights`, { params })
// 获取子权限菜单列表
const getChildMenuList = (params = {}) => request.get(`/children`, { params })
// 删除一级权限菜单
const delRight = (id) => request.delete(`/rights/${id}`, { id })
// 删除二级权限菜单
const delChildRight = (id) => request.delete(`/children/${id}`, { id })
// 控制一级权限菜单是否显示在菜单栏
const switchRight = (params = {}) => request.patch(`/rights/${params.id}`, params)
// 控制一级权限菜单是否显示在菜单栏
const switchChildRight = (params = {}) => request.patch(`/children/${params.id}`, params)
// 获取角色列表
const roleList = (params = {}) => request.get(`/roles`, { params })
// 删除角色
const delRole = (id) => request.delete(`/roles/${id}`, { id })
// 设置角色权限
const setRoleRights = (params = {}) => request.patch(`/roles/${params.id}`, params)
// 获取用户列表  Or  登录
const getUsersList = (params = {}) => request.get(`/users`, { params })
// 获取区域
const getRegionsList = (params = {}) => request.get(`/regions`, { params })
// 新增用户列表
const addUser = (params = {}) => request.post(`/users`,  params)
// 更新用户信息
const updateUserInfo = (params = {}) => request.patch(`/users/${params.id}`, params)
// 删除用户
const delUser = (id) => request.delete(`/users/${id}`, { id })
// 获取新闻分类列表
const newCategories = (params = {}) => request.get(`/categories`, { params })
// 更新新闻分类列表
const updatenewCategorie = (params = {}) => request.patch(`/news/${params.id}`, params)
// 删除新闻分类列表
const delnewCategorie = (params = {}) => request.delete(`/news/${params.id}`, params)
// 新增新闻
const addNews = (params = {}) => request.post(`/news`,  params)
// 获取新闻
const getNews = (params = {}) => request.get(`/news`, { params })
// 获取新闻详情
const getNewsInfo = (params = {}) => request.get(`/news/${params.id}`, { params })
// 删除新闻
const delNews = (id) => request.delete(`/news/${id}`, { id })
// 更新新闻
const updateNewsInfo = (params = {}) => request.patch(`/news/${params.id}`, params)


export {
  getMenuList,
  getChildMenuList,
  delRight,
  delChildRight,
  switchRight,
  switchChildRight,
  roleList,
  delRole,
  setRoleRights,
  getUsersList,
  getRegionsList,
  addUser,
  updateUserInfo,
  delUser,
  newCategories,
  addNews,
  getNews,
  delNews,
  getNewsInfo,
  updateNewsInfo,
  updatenewCategorie,
  delnewCategorie
}